#pragma once
#include<iostream>
#include<map>
#include<functional>

using namespace std;

namespace ns_task
{
    class Task
    {
    public:
        Task(int x = 1, int y = 1, char op = '+')
        :_x(x)
        ,_y(y)
        ,_op(op)
        {}
        void run()
        {
            int ans =  _func_map[_op](_x, _y);
            cout << "当前任务正在被【" << pthread_self() << "】处理: " << _x << " " << _op << " " << _y << " = " << ans << endl;
        }
        ~Task()
        {}
    private:
        int _x;
        int _y;
        char _op;
    public:
        static map<char,function<int(int,int)>> _func_map;
    };
    
    map<char,function<int(int,int)>> Task::_func_map = {
    {'+', [](int x, int y)->int{return x + y;}},
    {'-', [](int x, int y)->int{return x - y;}},
    {'*', [](int x, int y)->int{return x * y;}},
    {'/', [](int x, int y)->int{return x / y;}},
    {'%', [](int x, int y)->int{return x % y;}}
};

}